<template>
	<view class="page">
		<view style="background-color:#fff;height:80rpx;">
			<view class="navigation">
				<view class="nav-item" v-for="(item,index) in extdata" @click="tab(index)">
					<text> {{item.name}}</text>
					<view class="solid" v-if="type == index"> </view>
				</view>
			</view>
		</view>
		<My-JapaneseMoving ref="japanRefs"></My-JapaneseMoving>
	</view>
</template>
<script>
	import {
		Init
	} from '@/utils/user.js'
	import JapaneseMoving from '@/components/JapaneseMoving.vue';
	export default {
		components: {
			'My-JapaneseMoving': JapaneseMoving,
		},
		data() {
			return {
				itm: ['全日式', '半日式', '全屋收纳整理'],
				type: 1,
				extdata: [],
			}
		},
		onLoad() {
			this.Car()

		},
		methods: {

			modify() {
				this.$nextTick(() => {
					// 通过 $refs 获取子组件实例
					const loginComponent = this.$refs.japanRefs;
					var i = "Japanese"
					var e = 1
					var its = this.extdata[this.type]
					var ti = this.type
					
				

					// 调用子组件方法
					loginComponent.open(i, e, its, ti);

 
					if (e == 3) {
						loginComponent.uentestay()
					}




				});

			},


			Car() {
				Init().then(res => {
					this.Carinformation = res.data.data
					// 提取company、japanese和normal对象到数组中
					const extractedData = [];
					extractedData.push(res.data.data.normal);
					extractedData.push(res.data.data.japanese);
					extractedData.push(res.data.data.company);
					// 将company里的car_type属性改为和其他对象相同的type属性
					extractedData[2].type = extractedData[2].car_type;
					delete extractedData[2].car_type;
					console.log(extractedData, 888888);

					this.extdata = res.data.data.japanese.type

					this.modify()

				}).catch(error => {
					console.error('Init 方法执行出错：', error);
				});

			},

			tab(i) {
				this.type = i
				this.modify()
			}

		}
	}
</script>

<style scoped>
	.navigation {
		display: flex;
		width: 80%;
		background-color: #fff;
		margin: 0 auto;
	}

	.nav-item {
		flex: 1;
		text-align: center;
		line-height: 60rpx;
		cursor: pointer;
		display: flex;
		flex-direction: column;
		align-items: center;
		justify-content: center;
		color: rgb(102, 102, 102);
		font-family: "PingFang SC";

	}

	.solid {
		width: 90rpx;
		height: 6rpx;
		border-radius: 2rpx;
		background-color: rgb(43, 142, 255);
	}
</style>